﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class Enterprise : IAccessible<P_Enterprise, Enterprise>, ILogicEntity<P_Enterprise, Enterprise>
    {
        public int ID { get; set; }
        public string EnterpriseName { get; set; }
        public string EnterpriseCode { get; set; }
        public string EnterpriseCredit { get; set; }
        public string EnterpriceInfo { get; set; }
        public string CapitalOperation { get; set; }

        protected override void Covariant(P_Enterprise model)
        {
            if (model != null)
            {
                this.CapitalOperation = model.CapitalOperation;
                this.EnterpriceInfo = model.EnterpriceInfo;
                this.EnterpriseCode = model.EnterpriseCode;
                this.EnterpriseCredit = model.EnterpriseCredit;
                this.EnterpriseName = model.EnterpriseName;
                this.ID = model.ID;
            }
        }

        protected override P_Enterprise Inverter(Enterprise model)
        {
            if (model != null)
            {
                return new P_Enterprise()
                {
                    CapitalOperation = model.CapitalOperation,
                    EnterpriceInfo = model.EnterpriceInfo,
                    EnterpriseCode = model.EnterpriseCode,
                    EnterpriseCredit = model.EnterpriseCredit,
                    EnterpriseName = model.EnterpriseName,
                    ID = model.ID
                };
            }
            return null;
        }

        public Enterprise Set(P_Enterprise dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
